package code.temp.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

/**
 * <b>Description : </b>
 *
 * @author CPF
 * @date 2020/12/3 10:59
 **/
public class LogPrintTest {
    
    public static final Logger log = LoggerFactory.getLogger(LogPrintTest.class);

    public static void main(String[] args) {
        final String property = System.getProperty("file.encoding");
        if (!Charset.defaultCharset().name().equals(property)) {
            throw new RuntimeException("errerrer");
        }
        
        print("args" + Arrays.toString(args));
        print("file.encoding  " + System.getProperty("file.encoding"));
        print("Charset.defaultCharset().name()  " + Charset.defaultCharset().name());
        System.out.println();

        final String s = "信息";
        final byte[] bytes = s.getBytes();
        print("信息 : " + s);
        print("信息.toCharArray(): " + Arrays.toString(s.toCharArray()));
        print("信息.getBytes(): " + Arrays.toString(s.getBytes()));
        System.out.println();

        print("new String(信息.getBytes()) ==> " + new String(bytes));
        print("new String(信息.getBytes(), GBK) ==> " + new String(bytes, Charset.forName("GBK")));
        print("new String(信息.getBytes(), UTF_8) ==> " + new String(bytes, StandardCharsets.UTF_8));
    }

    public static void print(Object string) {
        log.info(string.toString());
        System.out.println(string.toString());
    }
}
